<template>
  <div>
    <!-- <p>宠物知识发布</p> -->
    <div>
      <el-row>
        <el-form>
          <el-form-item label="文章标题">
            <el-col :span="6" style=" margin-left: 3%" >
              <el-input v-model="model.title"></el-input>
            </el-col>
          </el-form-item>

          <el-form-item>
            <el-col>
              <mavon-editor v-model="model.content"></mavon-editor>
            </el-col>
          </el-form-item>

          <el-form-item>
            <el-col>
              <el-button
                type="primary"
                @click="submit"
                style="margin-top: 3%; margin-left: 40%; width: 10%"
                >发表</el-button
              >
            </el-col>
          </el-form-item>
        </el-form>
      </el-row>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      model: {
        title: "",
        content: "",
      },
    };
  },
  methods: {
    submit() {
      //console.log(this.model.content);
      let params = new URLSearchParams();
      params.append("content", this.model.content);
      params.append("title", this.model.title);
      axios
        .post(
          "http://localhost:9091/pet-knowledge/dogknowledge/add",
          params
          //添加文章
        )
        .then((resp) => {
          if (resp.data.code == 200) {
            this.$message.success("发布成功");
          } else {
            this.$message.info("发布失败");
          }
        });
    },
  },
  mounted() {},
  computed: {},
};
</script>
<style scoped></style>
